package com.xmb.wechat.delegate;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xmb.wechat.R;
import com.xmb.wechat.baserecyclerview.BaseRecyclerViewManager;
import com.xmb.wechat.entity.ChartBarEntity;

import java.util.ArrayList;

/**
 * @Author lijiangop
 * @CreateTime 2020/5/7 16:50
 */
public class ChartBarExtendDelegate extends BaseRecyclerViewManager {

    public ChartBarExtendDelegate(Context context, RecyclerView recyclerView) {
        super(context, recyclerView);
    }

    @Override
    public BaseQuickAdapter initAdapter() {
        return new BaseQuickAdapter<ChartBarEntity, BaseViewHolder>(R.layout.item_chart_bar, new ArrayList<>()) {
            @Override
            protected void convert(BaseViewHolder helper, ChartBarEntity item) {
                helper.setText(R.id.tv, TextUtils.isEmpty(item.getName()) ? "" : item.getName());
                helper.setImageResource(R.id.iv, item.getRes());
            }
        };
    }

    @Override
    protected RecyclerView.LayoutManager getLayoutManager() {
        return new GridLayoutManager(context, 4);
    }

    @Override
    protected RecyclerView.ItemDecoration getItenDecoration() {
        return null;
    }
}
